﻿using System.Collections.Generic;

namespace XospitalParser
{
    internal class LogFileParser
    {
        private readonly LineParser _lineParser;
        private readonly LogReader _logReader;

        public LogFileParser()
        {
            _logReader = new LogReader();
            _lineParser = new LineParser();
        }

        public IList<UserAction> Parse(string file)
        {
            IList<UserAction> list = new List<UserAction>();
            _logReader.ReadAndProcess(
                file,
                (i, s) =>
                    {
                        UserAction userAction = _lineParser.Parse(s);
                        if (userAction != null)
                            list.Add(userAction);
                    });
            return list;
        }
    }
}